package minStartValue;

public class Solution {
    public int minStartValue(int[] nums) {
        // 思路 找到最小的累加和 +1就是结果 startSum+minsum = 1;
        int minSum = nums[0];
        int prevSum = nums[0];
        for (int i = 1; i < nums.length ; i++) {
            int sum = prevSum + nums[i];
            minSum = Math.min(minSum,sum);
            prevSum = sum;
        }
        return Math.max(1,1-minSum);
    }
}
